/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package conexion;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author USUARIO
 */
public class Coneccion {
    
    private static String driver = "org.postgresql.Driver";
    private static String user = "postgres";
    private static String pass = "mysql";
    private static String url = "jdbc:postgresql://localhost:5432/pasajes";

    public static synchronized Connection getConexion()
    {
        Connection cn = null;
        try
        {
            Class.forName(driver);
            cn = DriverManager.getConnection(url,user,pass);
        } catch(Exception e)
        {
            cn = null;
        } finally
        {
            return cn;
        }
    }
    
    public static synchronized void cerrarCall(PreparedStatement ps)
    {
        try{ps.close();} catch(Exception e){}
    }
    public static synchronized void cerrarConexion(ResultSet rs)
    {
        try{rs.close();} catch(Exception e){}
    }
    public static synchronized void cerrarConexion(Connection cn)
    {
        try{cn.close();} catch(Exception e){}
    }
    public static synchronized void deshacerCambios(Connection cn)
    {
        try{cn.rollback();} catch(Exception e){}
    }
    
    
    
    
}

